
$.ajax({
  type: "GET",
  url: "/api/index/index",
  success: function (res) {
    console.log(res.data);

    var htmlStr1 = template("tpl-banner", res.data);
      console.log(htmlStr1);
      console.log(htmlStr2);
      $("#a-banner").html(htmlStr1);
      var htmlStr2 = template('tpl-channel', res.data)
      var htmlStr3 = template('tpl-brand', res.data)
      var htmlStr4 = template('tpl-goods', res.data)
      var htmlStr5 = template('tpl-popular', res.data)
      var htmlStr6 = template('tpl-grid', res.data)
      var htmlStr7 = template("tpl-list", res.data);
      // $('.m-menu').html(htmlStr2)
      $('#b-brand').html(htmlStr3)
      $('#b-goods').html(htmlStr4)
      $('#b-popular').html(htmlStr5)
      $('#g-grid').html(htmlStr6)
      $('#a-list').html(htmlStr7)
      layui.use("carousel", function () {
        var carousel = layui.carousel;
        //建造实例
        carousel.render({
          elem: "#test1",
          width: "100%", //设置容器宽度
          height: "100%",
          arrow: "none", //始终显示箭头
          //,anim: 'updown' //切换动画方式
          autoplay: "true",
          interval: 1000,
          // indicator: 'none'
        });
      });
     var swiper = new Swiper(".mySwiper", {
       slidesPerView: 1,
       spaceBetween: 0,
       loop: true,
       pagination: {
         el: ".swiper-pagination",
         clickable: true,
       },
       navigation: {
         nextEl: ".swiper-button-next",
         prevEl: ".swiper-button-prev",
       },
     });
   var swiper = new Swiper(".mySwiper2", {
     spaceBetween: 0,
     centeredSlides: true,
     loop: true,
     autoplay: {
       delay: 2500,
       disableOnInteraction: false,
     },
     pagination: {
       el: ".swiper-pagination1",
       clickable: true,
     },
   });
  },
});
$.ajax({
  type: "GET",
  url: "/api/goods/count",
  success: function (res) {
    console.log(res);
    var htmlStr = template('tpl-search', res.data)
    $('.search').html(htmlStr)
  }
});
